package com.ymttest.database.sqlwapper.godmch;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.serviceRelation;
import com.ymttest.utils.EnvSetup;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
/************************************************************************************
 * @Author : 吴文
 * @Date : 
 * @Copyright : 洋码头
 *godmach
 ************************************************************************************/
public class serviceRelationWapper {
	SqlManager manage;
	public serviceRelationWapper() {
		manage = new SqlManager("mysqlgodmchdb" + EnvSetup.getEnv());
		 
	}
 public  serviceRelation selectByPrimaryKey(Integer providerId,Integer mchId,Integer serviceType) throws InterruptedException {
	    Map map=new  HashMap();
	    map.put("providerId", providerId);
	    map.put("mchId", mchId);
	    map.put("serviceType", serviceType);
	    
		serviceRelation model=new serviceRelation();
		List<serviceRelation> list =  manage.getSelectResults("com.ymttest.database.mapping.godmch.serviceRelationMapper.selectByPrimaryKey",map);
		if(list.size()>0)
			model=list.get(0);
		manage.commit();
		return model;
	}
	
 public  Integer selectChannelNumByproviderId(Integer providerId) throws InterruptedException {
	    
		Integer channelNum=0;
		List<Map> list =  manage.getSelectResults("com.ymttest.database.mapping.godmch.serviceRelationMapper.selectChannelNumByproviderId",providerId);
		if(list.size()>0)
			channelNum=Integer.parseInt(list.get(0).get("channelNum").toString());
		manage.commit();
		return channelNum;
	}
	
 
 public  List<serviceRelation> selectByMchIdServiceType(Integer mchId,Integer serviceType) throws InterruptedException {
	    
	    Map map=new  HashMap();
	    map.put("mchId", mchId);
	    map.put("serviceType", serviceType);
		List<serviceRelation> list =  manage.getSelectResults("com.ymttest.database.mapping.godmch.serviceRelationMapper.selectByMchIdServiceType",map);

		manage.commit();
		return list;
	}
 
 
 public  List<serviceRelation> selectByProviderId(Integer providerId) throws InterruptedException {
	    
	    Map map=new  HashMap();
	    map.put("providerId",providerId);
		List<serviceRelation> list =  manage.getSelectResults("com.ymttest.database.mapping.godmch.serviceRelationMapper.selectByProviderId",map);

		manage.commit();
		return list;
	}
 
	public static void min(String args[]) throws InterruptedException {
	
	}
}
